﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.CMS263.PO;

namespace Com.CMS263.DAO
{
    public class ProductImageDAO : BaseService
    {
        public ProductImageDAO() { }
        public int GetMaxId()
        {
            string hql = "from ProductImage order by Id desc";
            try
            {
                ProductImage prod = FindList<ProductImage>(hql, null, 0, 1).First();
                return prod.Id + 1;
            }
            catch (Exception)
            {

                return 1;
            }
        }
        public IList<ProductImage> GetListByPager(int productid, int page, int pagesize)
        {
            string hql = " from ProductImage where 1=1 and ProductId=" + productid;
            hql += " order by SortId desc";
            return FindList<ProductImage>(hql, null, (page - 1) * pagesize, pagesize);
        }
        public int GetListByPager(int productid)
        {
            string hql = " select count(*) from ProductImage where 1=1 and ProductId=" + productid;
            return Convert.ToInt32(GetValue(hql));
        }
    }
}
